<?php
/* SVN FILE: $Id: member_form.php 177 2009-08-27 06:14:19Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* This file is to extend the member editing with ibMarket features
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 177 $
* @lastrevision $Date: 2009-08-27 06:14:19 +0000 (Thu, 27 Aug 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-08-27 06:14:19 +0000 (Thu, 27 Aug 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/extensions/admin/member_form.php $
*/

class admin_member_form__ibmarket implements admin_member_form
{	
	/**
	* Tab name
	* This can be left blank and the application title will
	* be used
	*
	* @access	public
	* @var		string		Tab name
	*/
	public $tab_name = "";

	
	/**
	* Returns sidebar links for this tab
	* You may return an empty array or FALSE to not have
	* any links show in the sidebar for this block.
	*
	* The links must have 'section=xxxxx&module=xxxxx[&do=xxxxxx]'. The rest of the URL
	* is added automatically.
	*
	* The image must be a full URL or blank to use a default image.
	*
	* Use the format:
	* $array[] = array( 'img' => '', 'url' => '', 'title' => '' );
	*
	* @access	public
	* @param    array 			Member data
	* @return   array 			Array of links
	*/
	public function getSidebarLinks( $member=array() )
	{
		ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_market' ), 'ibmarket' );
		
		$array = array();
				
		$array[] = array( 'img'   => '', 
						  'url'   => 'module=manage&amp;section=inventory',
						  'title' => ipsRegistry::getClass('class_localization')->words['link_manage_inventory'] );
		
		return $array;
	}
	
	/**
	* Returns content for the page.
	*
	* @access	public
	* @param    array 				Member data
	* @return   array 				Array of tabs, content
	*/
	public function getDisplayContent( $member=array() )
	{
		if(!class_exists('marketFormatter'))
		{
			require_once( IPSLib::getAppDir('ibmarket')."/sources/marketFormatter.php");
		}
		
		$this->html = ipsRegistry::getClass('output')->loadTemplate('cp_skin_member_form_ibmarket', 'ibmarket');
		
		ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_market' ), 'ibmarket' );
		
		return array( 'tabs' => $this->html->acp_member_form_tabs( $member ), 'content' => $this->html->acp_member_form_main( $member ) );
	}
	
	/**
	* Process the entries for saving and return
	*
	* @access	public
	* @return   array 				Multi-dimensional array (core, extendedProfile) for saving
	*/
	public function getForSave()
	{
		if(!class_exists('numbers'))
		{
			require_once( IPSLib::getAppDir('ibmarket')."/sources/numbers.php");
		}
		$return = array( 'core' => array(), 'extendedProfile' => array() );
		
		$settings = ipsRegistry::fetchSettings();
		
		$return['core']['market_access']					= max(min(intval(ipsRegistry::$request['market_access']), 1), -1);
		$return['core']['market_tax']						= numbers::parseFloat(ipsRegistry::$request['market_tax']);
		$return['core'][$settings['market_members_field']]	= numbers::parseInt(ipsRegistry::$request[$settings['market_members_field']]);
		
		return $return;
	}
}